﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace AbetEvaluation.Admin
{
	public partial class ManageUsers : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			lblError.Text = String.Empty;
		}

		protected void gvUsers_SelectedIndexChanged(object sender, EventArgs e)
		{
			List<MembershipUser> user = new List<MembershipUser>();
			user.Add(Membership.GetUser(gvUsers.SelectedValue.ToString()));
			dvUser.DataSource = user;
			dvUser.DataBind();
		}

		protected void gvUsers_RowDeleting(object sender, GridViewDeleteEventArgs e)
		{
			e.Cancel = true;
			if (User.Identity.Name.Equals(gvUsers.DataKeys[e.RowIndex].Value as String))
			{
				lblError.Text = "You can't delete yourself.";
			}
			else
			{
				Membership.DeleteUser(gvUsers.DataKeys[e.RowIndex].Value as String, true);
				gvUsers.DataBind();
			}
		}
	}
}